cmake_minimum_required(VERSION 3.10)
project(SDL2_OpenGL_Learning)

set(CMAKE_CXX_STANDARD 17)

#配置对应平台的库文件并探测对应平台的运行时文件
set(RUNTIME_FILE)
if(WIN32)
    if(MINGW)
        set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};thirdparty/win64_mingw/assimp/lib/cmake/assimp-5.2)
        set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};thirdparty/win64_mingw/sdl2/lib/cmake/SDL2)
        file(GLOB ASSIMP_RUNTIME_FILE thirdparty/win64_mingw/assimp/bin/*.dll)
        file(GLOB SDL2_RUNTIME_FILE thirdparty/win64_mingw/sdl2/bin/*.dll)
        set(RUNTIME_FILE ${ASSIMP_RUNTIME_FILE} ${SDL2_RUNTIME_FILE})
    elseif(MSVC)
        set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};thirdparty/win64_msvc/assimp/lib/cmake/assimp-5.2)
        set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};thirdparty/win64_msvc/sdl2/cmake)
        file(GLOB ASSIMP_RUNTIME_FILE thirdparty/win64_msvc/assimp/bin/*.dll)
        file(GLOB SDL2_RUNTIME_FILE thirdparty/win64_msvc/sdl2/bin/*.dll)
        set(RUNTIME_FILE ${ASSIMP_RUNTIME_FILE} ${SDL2_RUNTIME_FILE})
    endif()
endif()

#配置各个平台的额外的链接库
set(ADDITIONAL_LIBS)
if(WIN32)
    #Gl
    find_package(OpenGL REQUIRED)
    if(MINGW)
        set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS};mingw32)
    elseif(MSVC)
        set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS};)
    endif()
elseif(UNIX)
    set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS};dl)
endif()

# SDL2
find_package(SDL2 REQUIRED)

# Assimp
find_package(assimp REQUIRED)

add_subdirectory(common)
add_subdirectory(lesson1_shaderVAOLearning)
add_subdirectory(lesson2_TextureLearning)
add_subdirectory(lesson3_TransformationsLearning)
add_subdirectory(lesson4_CoordinateLearning)
add_subdirectory(lesson5_LightingLearning)
add_subdirectory(lesson6_MaterialLearning)
add_subdirectory(lesson7_MultLightLearning)
add_subdirectory(lesson8_ModelLoading)

add_custom_target(BuildAll DEPENDS lesson1 lesson2 lesson3 lesson4 lesson5 lesson6 lesson7 lesson8)